function [stModip, F2, Fm3] = DataExtract(mth)
%
% NeQuick-G Tables Data Extraction
%
%DESCRIPTION:
%This function extracts the data from the NeQuick-G furnished tables.
%
%PROTOTYPE:
% [stModip, CCIRF2, CCIRFm3] = DataExtraction(mth)
%
%--------------------------------------------------------------------------
% INPUTS:
%   mth         [1x1]      Month Number              [-]
%--------------------------------------------------------------------------
% OUTPUTS:
%   stModip     [39x39]    MODIP Table               [-]
%   CCIRF2      [1976x1]   F2 Coefficients           [-]
%   CCIRFm3     [882x1]    Fm3 Coefficients          [-]
%--------------------------------------------------------------------------
%
%NOTES:
% - The month number should be from 1 to 12 (e.g., Jan = 1, Aug = 8, etc.)
%
%CALLED FUNCTIONS:
% CCIRsorter
%
%UPDATES:
% (none)
%
%REFERENCES:
% [1] "Ionospheric Correction Algorithm for Galileo Single-Frequency Users"
%      - European GNSS (Galileo) Open Service
%
%AUTHOR(s):
%Luigi De Maria, Matteo D'Addazio, 2022
%

%% Modified Dip Latitude (MODIP)
%Note that here we have to shift rightward the MODIP table because in the
%documentation [1] it the columns start from -1 which means that the first
%column is the last one
stModip = readmatrix('./tables/modip/modip2001_wrapped.txt');
stModip = circshift(stModip, -1, 2);

%% Monthly Spherical Harmonic Coefficients (CCIR)
% n the F2 and Fm3: i = Solar Activity Index, j = Degree, k = Order

%Txt Table Extraction & Manipulation
[CCIRF2, CCIRFm3] = CCIRsorter(mth);

%Building of F2 Tensor
for i = 1 : 2
    for j = 1 : 76
        for k = 1 : 13
            J = j-1;
            I = i-1;
            F2(i,j,k) = CCIRF2(1,I*(76*13) + J*13 + k);
        end
    end
end
%Building of Fm3 Tensor
for i = 1 : 2
    for j = 1 : 49
        for k = 1 : 9
            J = j-1;
            I = i-1;
            Fm3(i,j,k) = CCIRFm3(1,I*(9*49) + J*9 + k);
        end
    end
end